<template>
  <el-dialog :visible.sync="show" width="450px" title="创建答疑">
    <el-row :gutter="24">
      <el-col :span="16">
        <el-input v-model="anwserTitle" placeholder="请输入答疑名称"></el-input>
      </el-col>
      <el-col :span="8">
        <el-button type="primary" @click="add">创建答疑</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import Qapi from '../../api/Question.js'
export default {
  props: {
    visible: Boolean
  },
  data() {
    return {
      anwserTitle: "",
      show: false
    };
  },
  watch: {
    visible: function(val) {
      this.anwserTitle = "";
      this.show = val;
    },
    show: function(val) {
      this.$emit("update:visible", val);
    }
  },
  methods: {
    loadPaylod(){
      return {
          username:this.$store.state.user.username,
          school:this.$store.state.user.school,
          question:this.anwserTitle,

      }

    },
    add(){
      this.show =false;
      this.axios.post(Qapi.add,this.loadPaylod()).then(res=>{
        if(res.data.status===0){
          this.$parent.loadSource();
        }
      })
    },
  }
};
</script>
<style>
</style>